Release 10.1A: OpenEdge Data Management:
DataServer for Microsoft SQL Server
Query tuning
How you structure a query determines how efficiently you access a database. Using your MSS data source efficiently enhances the performance of DataServer applications. The standard approach to enhancement is using selection criteria to refine access to data, but you can further optimize the DataServer’s execution of a query by specifying the Progress
QUERY–TUNINGphrase.You can include the
QUERY–TUNINGphrase in these Progress statements:You must place the
QUERY–TUNINGphrase after the last record phrase. For example, place it near the end of the statement where you also place block modifier phrases such asBREAK,ONERROR, andTRANSACTION.You can include multiple query-tuning options in a single statement; simply separate each option from the previous one by a single space.
Table 4–1 describes the query-tuning options.
Table 4–1: Query-tuning options Option DescriptionARRAY–MESSAGENO–ARRAY–MESSAGE Specifies whether the DataServer sends multiple result rows in a single logical network message, thereby reducing network traffic.Default:ARRAY–MESSAGE, if the query uses a lookahead cursor.CACHE–SIZEinteger Specifies the size in bytes of the cache used by lookahead cursors. A larger cache size can improve performance for queries that return a large number of records because the DataServer might need fewer SQL statements to get the results. This value will override a cache size specified with-DsrvQT_CACHE_SIZE.Minimum: The DataServer always caches at least one record.Maximum: None.Default: 30000.DEBUGEXTENDEDDEBUGSQLNO–DEBUG Specifies whether the DataServer should print to thedataserv.lgfile the debugging information that it generates for a query.SpecifyDEBUGSQLto print only the SQL that the DataServer executes against the ODBC data source.SpecifyDEBUGEXTENDEDto print additional information, such as cursor statistics.SpecifyDEBUGoptionto override theNO–DEBUGdefault.Default:NO–DEBUG.JOIN–BY–SQLDBNO–JOIN–BY–SQLDB Specifies whether the DataServer allows its data source to perform a join (this usually improves performance).JOIN–BY–SQLDBimpliesSEPARATE–CONNECTIONqueries that include joins.Default:JOIN–BY–SQLDB.JOIN–BY–SQLDBis a compile-time option. A query must be compiled to use or not use this option.You can turn off theJOIN–BY–SQLDBdefault globally at compile time by specifying the Server Join (-nojoinbysqldb) startup parameter when you start an OpenEdge session. This parameter does not override the explicit use ofJOIN–BY–SQLDBin theQUERY–TUNINGphrase.LOOKAHEADNO–LOOKAHEAD Specifies whether the DataServer uses lookahead or standard cursors. Lookahead cursors fetch as many records as fit in the allocated cache (see theCACHE–SIZEentry in this table). This reduces the number of SQL statements and network messages that are required, thereby improving performance.Using lookahead cursors results in behavior that is different from an OpenEdge database because changes made to the records in the cache might not be immediately visible. SpecifyNO–LOOKAHEADfor behavior that is consistent with OpenEdge.Default:LOOKAHEAD, when statements useNO-LOCKor when statements useSHARE-LOCKwithTXN_ISOLATIONlevel set to 1 (read uncommitted.)SEPARATE–CONNECTIONNO–SEPARATE–CONNECTION Specifies whether each cursor should use a separate database connection. Executing cursors in separate connections might improve performance because the DataServer does not have to restart the cursors and sort the results.Do not specifySEPARATE–CONNECTIONif you require behavior that is consistent with OpenEdge.Default:NO–SEPARATE–CONNECTIONexcept in certain cases. For details, see the "Managing connections to a MS SQL Server database" section.
All but two of the
QUERY–TUNINGoptions take effect at both compile time and run time. The exceptions areJOIN–BY–SQLDBandNO–JOIN–BY–SQLDB, which apply only at compile time. You can override query-tuning defaults (exceptJOIN–BY–SQLDB) at run-time by specifying the appropriate startup parameters.The following example shows how to use the
QUERY–TUNINGphrase to enhance performance. It includes a join,JOIN-BY-SQLDB, that the DataServer instructs the MSS data source to perform by default, as shown:
The
QUERY–TUNINGoptions in this example specify the following:When the DataServer constructs queries for an MSS data source, it uses the
Note: The DataServer does not issue errors or warnings if it does not apply theQUERY–TUNINGoptions that you specify as guidelines. This is because there might be syntax considerations that prevent the DataServer from applying theQUERY–TUNINGoptions as specified. In such a case, the DataServer executes the query using the most appropriate options.QUERY–TUNINGoptions that you specify.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |